
$(function() {
    var token = localStorage.phone;
    $("#btn_ipt").click(function() {
        var content = $("#content").val();

        if(content == "") {
            layer.msg('留言不能为空');
            return false;
        };
        $.ajax({
            url: "https://newapp.icandrive.cn/api/bug.php",
            data: {
                token: token,
                text: content
            },
            dataType: 'json',
            type: 'post',
            success: function(data) {
                if(data.status == 200) {
                    layer.msg("提交成功");
                    setInterval(function() {
                        window.location.href = "javascript:history.back(-1)";
                    }, 3000);
                }

                if(data.status == 250) {
                    layer.msg("请重新登录");
                    setInterval(function() {
                        window.location.href = "../login/log_in.html";
                    }, 3000);
                }
                if(data.status == 400) {
                    layer.msg("提交留言失败");
                    return false;
                }

            },

            error: function() {
                layer.msg('系统繁忙');
            }
        });

    })

    /*监听手机返回按键*/
    return_keybord();
})
